
import { prod, storeup, addBuycar } from '@/services'


const state = {
    prodlist: {},
    shopId: 1,
    pic: "",
    imgs: '',
    prodName: '',
    price: 0,
    content: '',
    prodId: 0,
    brief: '',
    skuId: 0,
    popupShow: false,
    // 是否获取过用户领取过的优惠券id
    loadCouponIds: false,
    skuShow: false,
    commentShow: false,
    couponList: [],
    skuList: [],
    skuGroup: {},
    findSku: true,
    defaultSku: undefined,
    selectedProp: [],
    selectedPropObj: {},
    propKeys: [],
    allProperties: [],
    prodCommData: {},
    prodCommPage: {
        current: 0,
        pages: 0,
        records: []
    },
    littleCommPage: [],
    evaluate: -1,
    isCollection: false
}
// “getters:类似是Vuex中的计算属性,也具有缓存功能:
// 如果state中的数据得到了改变,那么getters中的属性的值也会发生改变,
// 如果state的值没有发生任何变化,那么getters中的属性,的值就不会发生改变”
const getters = {};

// 异步
const mutations = {
    get_prodobj(state, payload) {
        state.prodlist = payload.prodlist
    }
}
// 同步
const actions = {
    async prodobj({ commit }, payload) {
        let result = await prod(payload)
        if (result) {
            commit('get_prodobj', { prodlist: result })
        }
    },

    async storeup({ commit }, payload) {
        let result = await (payload)
        if (result) {
            commit('get_storeup', { storeupobj: result })
        }
    },
    // 加入购物车
    async addBuycar({ commit }, payload) {
        let result = await addBuycar(payload);
    }

}


export default {
    namespaced: true,
    modules: {},
    state, getters, mutations, actions
}